home *** CD-ROM | disk | FTP | other *** search
- /* Obsolete.c: Obsolete applet for ProjectDrag
- *
- * A set of applets for drag and drop source control by Tim Maroney.
- * See develop, issue 23 for details.
- *
- * Built on DropShell by Leonard Rosenthol, Stephan Somogyi, and Marshall Clow,
- * and using the MoreFiles utilities by Jim Luther.
- *
- * This software is free, but don't modify and redistribute it without
- * changing the status window to indicate your name and your changes!
- */
-
-
- #include <Errors.h>
-
- #include "DSUserProcs.h"
- #include "SourceServer.h"
- #include "PDDialogs.h"
- #include "TasksAndErrors.h"
-
-
- void ObsoleteFile(FSSpec *file);
-
-
- /* This routine is called for each file passed in the ODOC event. */
-
- pascal void OpenDoc ( FSSpecPtr myFSSPtr, Boolean opening, Handle userDataHandle )
- {
- #pragma unused ( opening )
- #pragma unused ( userDataHandle )
-
- ObsoleteFile(myFSSPtr);
- }
-
-
- void ObsoleteFile(FSSpec *file)
- {
- Str63 userName;
- Str15 nickname;
- AEDesc command;
- Str255 projectName;
- OSErr err;
- CKIDHandle theCKID;
-
- TaskStart(2001, 1, file->name, NULL, NULL, NULL);
-
- /* confirm the obsoletion */
- if (!ResTextYesNo(2002, 1, file->name, NULL, NULL, NULL))
- {
- RaiseErrorNumber(userCanceledErr);
- return;
- }
-
- /* find the user name and initials */
- err = GetUserSettings(userName, nickname, false);
- if (err != noErr)
- {
- gDone = true;
- return;
- }
-
- /* get the CKID */
- err = ExtractCKID(file, &theCKID);
- if (err != noErr)
- {
- RaiseErrorString(kProjectDragStrings, kCantGetCKID, file->name,
- NULL, NULL, NULL);
- return;
- }
-
- /* Make sure the file is checked in. */
- if ((*theCKID)->writeable || (*theCKID)->modifyReadOnly)
- {
- DisposeHandle((Handle)theCKID);
- RaiseErrorString(2002, 2, file->name, NULL, NULL, NULL);
- return;
- }
-
- /* mount the project */
- err = MountProjectFromCKID(theCKID, projectName);
- DisposeHandle((Handle)theCKID);
- if (err != noErr) return;
-
- /* create an ObsoleteProjectorFile command for SourceServer
- * ObsoleteProjectorFile -project <project> -u <user> <file>
- */
- err = CreateCommand(&command, "ObsoleteProjectorFile");
- if (err == noErr)
- err = AddProjectArg(&command, projectName);
- if (err == noErr)
- err = AddUserArg(&command, userName);
- if (err == noErr)
- err = AddPStringArg(&command, file->name);
- if (err != noErr)
- {
- AEDisposeDesc(&command);
- RaiseErrorNumber(err);
- return;
- }
-
- err = SendCommand(&command); /* send the command to SourceServer */
- if (err != noErr) return;
-
- err = FSpDelete(file); /* don't worry about delete failures */
-
- TaskDone();
- }
-
-
- void DoFileMenu(short itemID)
- {
- if ( itemID == 1 )
- SelectFile(); // call file selection userProc
- else
- SendQuitToSelf(); // send self a 'quit' event
- }
-